#!/usr/bin/bash

operate_date=`date  -d "-4 day" +%Y%m%d`
if [[ $# -eq 1 ]]
then
	operate_date=$1
fi
recursion(){
	if [[ -d $1 && ! -z $1 ]];then
		for d in `ls $1`
		do
			tmp=$1/$d
			i=$(echo $tmp | grep -c "dt=")
			if [[ $i -eq 1 ]];then
				op_date=$(echo $d | cut -d"=" -f2)
				if [[ $op_date -le $operate_date ]];then
					#rm
					echo "rm -rf $tmp"
					rm -rf $tmp
				fi
			else
				recursion $tmp
			fi
		done
	fi
}
recursion "/home/work/workToHadoop"
